<?php

/*
 * yangzhic
 * 2016年8月16日下午3:29:03
 * ActivityController
 */
namespace SDXApi\Controller;

use Think\Controller;

class ActivityController extends AppController {
	public function _initialize($apptoken, $apptime) {
		parent::_initialize ( $apptoken, $apptime ); //
	}
	
	/*
	 * 获取优惠活动列表
	 */
	public function optimize_activity_list() {
		$user_rank = I ( 'post.user_rank' );
		$page = I ( 'post.page' );
		
		$user_rank = ! empty ( $user_rank ) ? $user_rank : 0;
		$page = ! empty ( $page ) ? $page : 0;
		
		$activity = D ( 'favourable_activity' );
		
		$activitylist = $activity->get_activity_list ( $user_rank, $page );
		if ($activitylist) {
			returnApiSuccess ( $activitylist );
		} else {
			returnApiError ( 'no data' );
		}
	}
	
	/*
	 * 获取优惠活动商品列表
	 */
	public function optimize_activity_goodslist() {
		$act_id = I ( 'post.act_id' );
		$page = I ( 'post.page' );
		$wid=I('post.wid','intval');
		if (empty ( $act_id )) {
			returnApiError ( 'act_id为空' );
		}
		$page = ! empty ( $page ) ? $page : 0;
		
		$activity = D ( 'favourable_activity' );
		
		$activitylist = $activity->get_activity_goods( $act_id, $page,$wid);
		if ($activitylist) {
			returnApiSuccess ( $activitylist );
		} else {
			returnApiError ( 'no data' );
		}
	}
}

?>